package com.yuand.controller;

import com.yuand.config.Result;
import com.yuand.entity.Menu;
import com.yuand.entity.MenuTree;
import com.yuand.mapper.MenuMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author yuandong
 * @date 2021/9/2 15:37
 */
@RestController
@RequestMapping("/sys")
public class MenuTreeController {

    @Autowired
    private MenuMapper menuMapper;

    @GetMapping("/menuTree")
    public Result<?> getMenuTree(){
        List<Menu> menus = this.menuMapper.selectList(null);
        MenuTree menuTree=new MenuTree(menus);
        List<Menu> menuList = menuTree.builTree();
        return Result.success(menuList);
    }


}
